/*
*
==============================================================================
*  Name        : 
*  Part of     : Omen Game Engine
*  Description : 
*  Version     : 1.0
*
*  Copyright (c) 2013 Lauri Kortevaara.
* 
==============================================================================
*/

#define OMEN_SOURCE 1

#include "OmenSceneManager.h"

using namespace Omen;

/// <summary>SceneManager constructor</summary>
SceneManager::SceneManager(Omen::IObject* pParent) 
    : m_pCurrentRenderer(NULL),
      m_pCurrentScene(NULL)
{
    // Omen::IObject
    this->setParent(pParent);
}

/// <summary>SceneManager copy constructor</summary>
SceneManager::SceneManager( const SceneManager& other )
{
    m_listRenderers = other.m_listRenderers;
    m_listScenes = other.m_listScenes;

    m_pCurrentRenderer    = other.m_pCurrentRenderer;
    m_pCurrentScene        = other.m_pCurrentScene;
}

/// <summary>SceneManager destructor</summary>
SceneManager::~SceneManager()
{
}

/// <summary>Get all Renderers added to the scene manager</summary>
unsigned int SceneManager::getRenderers( const IRenderer** pListRenderers, unsigned int maxSize )
{
    unsigned int numPtr = min(maxSize, this->m_listRenderers.size() );
    for( unsigned int i=0; i < numPtr; ++i )
        pListRenderers[i] = m_listRenderers[i];

    return numPtr;
}

/// <summary>Return the number of Renderers in the scene manager</summary>
unsigned int SceneManager::rendererCount() const
{
    return m_listRenderers.size();
}

/// renderers
/// <summary>Add a new renderer to the SceneManager</summary>
void SceneManager::addRenderer( const IRenderer* pRenderer )
{
    m_listRenderers.push_back(pRenderer);
}

/// <summary>Return currently active renderer</summary>
const IRenderer* SceneManager::currentRenderer() const
{
    return m_pCurrentRenderer;
}

/// <summary>Sets the currently active camera</summary>
void SceneManager::setCurrentRenderer( const IRenderer* pRenderer )
{
    m_pCurrentRenderer = pRenderer;
}


/// scenes
/// <summary> Add a new scene to the scene manager</summary>
void SceneManager::addScene( IScene* pScene )
{
    m_listScenes.push_back(pScene);
}

/// <summary>Get all or maxSize of Scenes added to the scene manager</summary>
unsigned int SceneManager::getScenes( const IScene** pListScenes, unsigned int maxSize )
{
    unsigned int numPtr = min(maxSize, this->m_listScenes.size() );
    for( unsigned int i=0; i < numPtr; ++i )
        pListScenes[i] = m_listScenes[i];

    return numPtr;
}

/// <summary>Return the number of Scenes in the scene manager</summary>
unsigned int SceneManager::sceneCount() const
{
    return m_listScenes.size();
}


/// <summary>Get current scene</summary>
IScene* SceneManager::currentScene()
{
    return m_pCurrentScene;
}

/// <summary>Set current scene</summary>
void SceneManager::setCurrentScene( IScene* pScene )
{
    m_pCurrentScene = pScene;
}

/// EOF